package helpers;

import java.util.ArrayList;

import helpers.StringHelper;

public class SoftwareHelper {
	public static String getPrice(float price, String currency) {
		String rCurrency = "$";
		String result = "";
		if (price > 0) {
			if(currency.toLowerCase().equalsIgnoreCase("usd")) {
				rCurrency = "$";
			}
			
			String[] str = Float.toString(price).split("[.]");
			result = rCurrency + str[0] + " <span class=\"cents\">" + str[1] + "</span><span class=\"misc\"></span>";
		} else {
			result = "<span class=\"cents\"></span><span class=\"misc\">Free</span>";
		}
		return result;
	}
	
	public static ArrayList<String> getSupportDevice(String str) {
		str = str.replace("[", "").replace("]", "").replace("\"", "");
		String[] arr = str.split(",");
		ArrayList<String> result = new ArrayList<String>();
		if (arr.length > 0) {
			for (int i = 0; i < arr.length; i++) {
				if (arr[i].equalsIgnoreCase("all")) {
					result.add("iPod touch, iphone And Ipad");
				} else if (arr[i].equalsIgnoreCase("iPodTouchourthGen")) {
					result.add("iPod touch (4th generation)");
				} else if (arr[i].equalsIgnoreCase("iPadWifi")) {
					result.add("iPad wifi");
				} else if (arr[i].equalsIgnoreCase("iPad23G")) {
					result.add("iPad2 3G");
				} else if (arr[i].equalsIgnoreCase("iPad3G")) {
					result.add("iPad 3G");
				} else if (arr[i].equalsIgnoreCase("iPhone-3GS")) {
					result.add("iPhone 3GS");
				} else if (arr[i].equalsIgnoreCase("iPodTouchThirdGen")) {
					result.add("iPod touch (3rd generation)");
				} else if (arr[i].equalsIgnoreCase("iPad2Wifi")) {
					result.add("iPad2 Wifi");
				} else {
					result.add(arr[i]);
				}
			}
		}
		return result;
	}
	
	public static String getIdFromInfoUrl(String str) {
		String ip = "";
		String regex = "[0-9]+$";
		ArrayList<String> ips = StringHelper.findString(regex, str);
		if (ips.size() > 0) {
			ip = ips.get(0);
		}
		return ip;
	}
	
	public static void main(String[] args) {
		getIdFromInfoUrl("kick-the-boss-504656060");
	}
}
